Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

664
Views
How to fix TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role

I'm running into a problem when I'm trying to create a role and a text channel. The role created will set permissions for the text channel.

if (id === '4') {
  message.guild.roles.create({
    name: `Owner`,
    color: `${color.white}`,
    permissions: ['ADD_REACTIONS'],
    hoist: true,
  });

  let owner = message.guild.roles.cache.find((role) => role.name === 'Owner');

  name = `${names.name}`,
    message.guild.channels
      .create(name, {
        type: 'GUILD_TEXT',
        permissionOverwrites: [
          {
            id: owner,
            allow: ['ADD_REACTIONS'],
            deny: ['VIEW_CHANNEL'],
          },
        ],
      })
      .catch((err) => console.log(err));
}

Although it creates the role, when it comes to the text channel, it cannot find the role made and throws an error:

TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.

I'm unsure how to fix this.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It looks like you haven't awaited the role create a function. Try using this code:

 if(id === '4'){


        await message.guild.roles.create({
            name: `Owner`,
            color: `${color.white}`,
            permissions: ["ADD_REACTIONS"],
            hoist: true
        });


        let owner = message.guild.roles.cache.find(role => role.name === "Owner");

        name = `${names.name}`,
        await message.guild.channels.create(name, {
            type: "GUILD_TEXT",  
            permissionOverwrites: [{
                id: owner,
                allow: ['ADD_REACTIONS'],
                deny: ['VIEW_CHANNEL']
            }]
        }).catch(err => console.log(err));

    }
about 4 years ago · Juan Pablo Isaza Report

0

roles.create() is an asynchronous method, which means it returns a promise and allows the rest of your code to run without blocking anything. It also means that when you try to find the newly created role on the next line, it won't be there as it's not even created, so it will be undefined. As undefined is not a valid Role or User, you receive a TypeError.

However, roles.create() resolves to the newly created role, so you can wait for it to be created (using await for example) and grab its value. This way you don't even need to find it later. Check out the code below:

let owner = await message.guild.roles.create({
  name: `Owner`,
  color: color.white,
  permissions: ['ADD_REACTIONS'],
  hoist: true,
});

message.guild.channels
  .create(names.name, {
    type: 'GUILD_TEXT',
    permissionOverwrites: [
      {
        // now owner is a valid role
        id: owner,
        allow: ['ADD_REACTIONS'],
        deny: ['VIEW_CHANNEL'],
      },
    ],
  })
  .catch((err) => console.log(err));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!